$("#firstId").change(function () {
    var firstId = $(this).val();

    if(firstId==0) {
        $("#secondId").empty().html('<option value="0">请选择二级分类</option>');
        $("#thridId").empty().html('<option value="0">请选择三级分类</option>');
        return;
    }

    var class_path = $("#form1").attr("class_path");
    $.ajax({
        type: "get",
        url: class_path + "/listByFirstId",
        data: {firstId: firstId},
        success: function (secondClasses) {
           var content='<option value="0">请选择二级分类</option>';

           $(secondClasses).each(function (index,item) {
               content+='<option value="'+item.id+'">'+item.className+'</option>';
           });

           $("#secondId").empty().html(content);
           $("#thridId").empty().html('<option value="0">请选择三级分类</option>');
        }
    });
})

$("#secondId").change(function () {
    var secondId = $(this).val();

    if(secondId==0) {
        $("#thridId").empty().html('<option value="0">请选择三级分类</option>');
        return;
    }
    var class_path = $("#form1").attr("class_path");
    $.ajax({
        type: "get",
        url: class_path + "/listBySecondId",
        data: {secondId: secondId},
        success: function (thridClasses) {
            var content='<option value="0">请选择三级分类</option>';

            $(thridClasses).each(function (index,item) {
                content+='<option value="'+item.id+'">'+item.className+'</option>';
            });

            $("#thridId").empty().html(content);
        }
    });
})